<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>旋转数组</title>
</head>
<body>
  <script>
    function fn(arr, n) {
      for(let i = 0; i < n; i++) {
        // 把数组末尾元素的删除，再添加到数组开头
        arr.unshift(arr.pop())
      }
      return arr
    }
    console.log(fn([0, 1, 2, 4, 5, 6, 7], 4))
  </script>
</body>
</html>